<template>
	<div class="page-wrap">
		<page-title></page-title>
		<div class="back">
			<el-button @click="goback" type="primary" size="small">返回</el-button>
		</div>
		<div class="page-content">
			<div class="page-row">
				<div class="box-right">
					<div class="table-box">
						<el-tabs v-model="activeTab" class="flex-tabs">
							<!-- <el-tab-pane name="1" :disabled="this.basic_Data.OCENDAT1001=='TRUE'" label="长期设置" lazy>
								<longTermSet ref="long" :basicDataF="basicData" v-on:changeActiveTab="changeActive($event)"></longTermSet>
							</el-tab-pane> -->
							<el-tab-pane
								name="2"
								:disabled="this.showactiveTab < 2 || this.basicData.OCENDAT1001=='TRUE' "
								label="器官设置"
								lazy
							>
								<apparatusSet :basicDataF="basicData" v-on:changeActiveTab="changeActive($event)"></apparatusSet>
							</el-tab-pane>
							<el-tab-pane
								name="3"
								:disabled="this.showactiveTab < 3 || this.basicData.OCENDAT1001=='TRUE'"
								label="扩散设置"
								lazy
							>
								<diffusionSet :basicDataF="this.basicData" v-on:changeActiveTab="changeActive($event)"></diffusionSet>
							</el-tab-pane>
							<el-tab-pane
								name="4"
								:disabled="this.showactiveTab < 4 || this.basicData.OCENDAT1001=='TRUE'"
								label="人口设置"
								lazy
							>
								<populationSet :basicDataF="this.basicData" v-on:changeActiveTab="changeActive($event)"></populationSet>
							</el-tab-pane>
							<el-tab-pane
								name="5"
								:disabled="this.showactiveTab < 5 || this.basicData.OCENDAT1001=='TRUE'"
								label="活动因子"
								lazy
							>
								<activeDivisor :basicDataF="this.basicData" v-on:changeActiveTab="changeActive($event)"></activeDivisor>
							</el-tab-pane>
							<el-tab-pane
								name="6"
								:disabled="this.showactiveTab < 6 || this.basicData.OCENDAT1001=='TRUE'"
								label="撤离隐蔽"
								lazy
							>
								<evacuateSet :basicDataF="this.basicData" v-on:changeActiveTab="changeActive($event)"></evacuateSet>
							</el-tab-pane>
							<el-tab-pane
								name="7"
								:disabled="this.showactiveTab < 7 || this.basicData.OCENDAT1001=='TRUE'"
								label="早期阶段器官设置"
								lazy
							>
								<earlyApparatu :basicDataF="this.basicData" v-on:changeActiveTab="changeActive($event)"></earlyApparatu>
							</el-tab-pane>
							<el-tab-pane
								name="8"
								:disabled="this.showactiveTab < 8 || this.basicData.OCENDAT1001=='TRUE'"
								label="结果输出设置"
								lazy
							>
								<result-output :basicDataF="this.basicData" v-on:changeActiveTab="changeActive($event)"></result-output>
							</el-tab-pane>
						</el-tabs>
					</div>
				</div>
			</div>
		</div>
	</div>
</template>

<script>
import longTermSet from "./longTermSet.vue"
import apparatusSet from "./apparatusSet.vue"
import diffusionSet from "./diffusionSet"
import populationSet from "./populationSet"
import activeDivisor from "./activeDivisor"
import evacuateSet from "./evacuateSet.vue"
import resultOutput from "./resultOutput.vue"
import earlyApparatu from "./earlyApparatu"
import { mapState } from "vuex"
import { BATCH_DETAIL, SS_ZAOQI_SEARCH } from "@/service/hd5.js"
export default {
	components: {
		longTermSet,
		apparatusSet,
		diffusionSet,
		populationSet,
		activeDivisor,
		evacuateSet,
		resultOutput,
		earlyApparatu,
	},
	data() {
		return {
			activeTab: "2",
			basicData: {
				batchid: this.$route.query.id,
				GENUMRAD001: "",
				id: "1",
				zaoqiList: [],
				aiZhengList: [],
				OCENDAT1001: "",
				MIORGDEF_ORG1: [],
				MIORGDEF_ORG2: [],
			},
		}
	},
	computed: {
		...mapState({
			showactiveTab: (state) => state.token.early_show_Tab,
			basic_Data: (state) => state.token.basic_Data,
			early_Data: (state) => state.token.early_Data,
		}),
	},

	created() { 
		this.$emit("changeActiveTab", this.activeTab)
		this.$store.dispatch("change_early_showTab", this.activeTab)
		this.getzaoqi()
		this.getAiZheng()
		this.getBasicData()
		this.router()
		this.getMIORGDEF_ORG1()
		this.getMIORGDEF_ORG2()
		this.getEarly_Data()
	},
	methods: {
		//配置面包屑
		router() {
			let temproute = []
			let advert = {
				resrName: "早期模块",
			}
			temproute.push(advert)
			this.$store.commit("updateRoute", temproute)
		},
		goback() {
			this.$router.go(-1)
		},
		getBasicData() { 
			this.basicData.OCENDAT1001 = this.basic_Data.OCENDAT1001
			let params = {
				batchid: this.$route.query.id,
				batchinfo: "BASE",
			} 
			this.$appApi
				.BATCH_DETAIL(params)
				.then((res) => {
					var str = res.data.substring(0, 1)
					if (str == "E") {
						let message = res.data.substring(6)
						this.$notify.error({
							title: "请求数据失败！",
							message: message,
							type: "success",
						})
					} else if (str == "S") {
						let tempdata = JSON.parse(res.data.substring(8))
						this.$store.dispatch("upData_basic_Data", tempdata) 
					}
				})
				.catch((err) => {
					console.log(err)
				})
		},
		getEarly_Data() {
			this.basicData.OCENDAT1001 = this.basic_Data.OCENDAT1001
			let params = {
				batchid: this.$route.query.id,
				batchinfo: "ZAOQI",
			} 
			this.$appApi
				.BATCH_DETAIL(params)
				.then((res) => {
					var str = res.data.substring(0, 1)
					if (str == "E") {
						let message = res.data.substring(6)
						this.$notify.error({
							title: "请求数据失败！",
							message: message,
							type: "success",
						})
					} else if (str == "S") {
						let tempdata = JSON.parse(res.data.substring(8)) 
						this.$store.dispatch("change_early_showTab", tempdata.SETPAGEINDEX)
						this.$store.dispatch("upData_early_Data", tempdata) 
						this.$refs.long.getData()
					}
				})
				.catch((err) => {
					console.log(err)
				})
		},
		getzaoqi() {
			this.$appApi
				.SS_ZAOQI_SEARCH()
				.then((res) => {
					var str = res.data.substring(8)
					this.basicData.zaoqiList = JSON.parse(str) 
				})
				.catch((err) => {
					console.log(err)
				})
		},
		getAiZheng() {
			this.$appApi
				.SS_AIZHENG_SEARCH()
				.then((res) => {
					var str = res.data.substring(8)
					this.basicData.aiZhengList = JSON.parse(str)  
				})
				.catch((err) => {
					console.log(err)
				})
		},
		getMIORGDEF_ORG2() {
			let params = {
				dictypeid: 2,
			} 
			this.loading = true
			this.$appApi
				.ZD_GET_DICINFOS(params)
				.then((res) => { 
					var str = res.data.substring(8) 
					this.basicData.MIORGDEF_ORG2 = JSON.parse(str) 
					this.loading = false
				})
				.catch((err) => {
					console.log(err)
				})
		},
		getMIORGDEF_ORG1() {
			let params = {
				dictypeid: 1,
			} 
			this.loading = true
			this.$appApi
				.ZD_GET_DICINFOS(params)
				.then((res) => { 
					var str = res.data.substring(8) 
					this.basicData.MIORGDEF_ORG1 = JSON.parse(str)
				})
				.catch((err) => {
					console.log(err)
				})
		},

		changeActive(value) { 
			this.activeTab = value
		},
	},
}
</script>